package ca.uwindsor.cs.deepweb.utility.wikipedia;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

import ca.uwindsor.cs.deepweb.estimation.DocumentHanlder;

public class WikiDocumentHandler implements DocumentHanlder {
	
	protected String title;
	
	protected String content;
	
	protected File file;
	
	protected String encoding;

	public WikiDocumentHandler(File file, String encoding) {
		this.file = file;
		this.encoding = encoding;
	}

	public String getContent() {
		// TODO Auto-generated method stub
		return content;
	}

	public String getTitle() {
		// TODO Auto-generated method stub
		return title;
	}

	public void processContent() throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
		title=reader.readLine();
		StringBuffer buffer = new StringBuffer();
		String string_line = reader.readLine();
		while (string_line != null) {
			buffer.append(string_line);
			buffer.append("\n");
			string_line = reader.readLine();
		}
		content = buffer.toString();
		reader.close();
	}

}
